<template>
<section class="reg">
  <div class="form-box">
    <div class="form-group mb20">
      <label class="label-icon">
                    <img src="../../assets/images/ioc_1.png" />
                </label>
      <div class="input-group">
        <input type="text" placeholder="请输入用户名" class="input input-login" v-model="userName">
      </div>
    </div>
    <div class="form-group">
      <label class="label-icon">
                    <img src="../../assets/images/ioc_2.png" />
                </label>
      <div class="input-group">
        <input type="password" placeholder="请输入密码" class="input input-login" v-model="password">
      </div>
    </div>
  </div>
  <div class="btn-group">
    <button class="btn btn-default login-btn" @click="toreg()">确认</button>
  </div>
</section>
</template>
<script>
import regService from "../../service/reg";
export default {
  data() {
    return {
      userName: "",
      password: ""
    }

  },
  methods: {
    toreg() {
      var name = this.userName,
        pwd = this.password;
      if (name == "") {
        alert("请输入用户名");
        return;
      } else if (pwd == "") {
        alert("请输入密码");
        return;
      }
      var params = {
        name: name,
        pwd: pwd
      }
      regService.reg(params)
        .then(res => {
          if (res.ret == "0000") {
            alert("注册成功");
            this.$router.push({
              path: "/login"
            })
          } else {
            alert(res.msg);
          }
        })
    }
  }
}
</script>
<style>
</style>
